package http;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpClient{
	//UrlConnection,HttpClien,OkHttp
	public static void main(String[] args) throws Exception{
		URL url=new URL("http://localhost:8080/zzWebServer/login");
		HttpURLConnection con=(HttpURLConnection) url.openConnection();
		con.setRequestMethod("POST");
		con.addRequestProperty("Cookie", "SESSIONID=B290FE01BC0D8C9974FB08172755AD36");
		con.setDoOutput(true);
		OutputStream out=con.getOutputStream();
		out.write("uname=john&psd=1234".getBytes());
		InputStream in=con.getInputStream();
		BufferedReader reader=new BufferedReader(new InputStreamReader(in, "gbk"));
		
		String line=null;
		while((line=reader.readLine())!=null){
			System.out.println(line);
		}
		out.close();
		reader.close();
		con.disconnect();
	}
}
